home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
mus
/
play
/
MP132src.lha
/
flashywin.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-14
|
8KB
|
286 lines
/*
* MultiPlayer
* Copyright (C) 1992 Bryan Ford
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* I (the author of MultiPlayer) can be contacted on the Internet at
* "bryan.ford@m.cc.utah.edu". See "Player.doc" for other addresses.
*
* $Id: flashywin.c,v 4.4 92/07/19 18:07:29 BAF Exp $
*
* $Log: flashywin.c,v $
* Revision 4.4 92/07/19 18:07:29 BAF
* Adjustment for putting localdata back into RemindNodes
*
* Revision 4.3 92/07/12 08:27:16 BAF
* Fixed stupid migration crashing bug
*
* Revision 4.2 92/06/21 11:12:56 BAF
* Migrated regargs to stdargs
*
* Revision 4.1 92/06/06 19:56:32 BAF
* Major_code_cleanup
*
* Revision 3.1 92/05/25 07:53:12 BAF
* GNU-ized.
*
*
*/
/* System includes */
#include <exec/types.h>
#include <exec/tasks.h>
#include <exec/semaphores.h>
#include <exec/execbase.h>
#include <dos/dos.h>
#include <intuition/intuition.h>
#include <libraries/asl.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
#include "bry/macros.h"
#include "bry/remind.h"
#include "bry/guido.h"
#include "player.h"
extern struct ExecBase *SysBase;
extern char prefsglob[];
extern GuidoSpec spectrumwinspec, scopewinspec, qscopewinspec, notewinspec;
extern short spectrumwinleft, scopewinleft, qscopewinleft, notewinleft;
extern char flashactive;
extern struct Task *flashytaskptr;
extern struct Task flashytask;
extern struct SignalSemaphore flashysem;
struct Gadget *spectrumboxgad;
struct Gadget *scopeboxlgad, *scopeboxrgad;
struct Gadget *noteboxgad;
struct Gadget *qscopeboxltgad, *qscopeboxrtgad, *qscopeboxlbgad;
static int close(int remake,struct MPWin *win);
static long checkspectrum(long sigmask);
static void spectruminit(void);
struct RastPort *spectrumrastport;
static struct MPWin spectrummpwin = {spectrumwinspec,&spectrumwinleft,spectruminit,
{0},{{0},checkspectrum,(long)&spectrummpwin},{{0},close,(long)&spectrummpwin},&spectrumrastport};
short spectrumboxleft, spectrumboxtop;
static long checkscope(long sigmask);
static void scopeinit(void);
struct RastPort *scoperastport;
static struct MPWin scopempwin = {scopewinspec,&scopewinleft,scopeinit,
{0},{{0},checkscope,(long)&scopempwin},{{0},close,(long)&scopempwin},&scoperastport};
short scopeboxlleft, scopeboxrleft, scopeboxtop;
static long checkqscope(long sigmask);
static void qscopeinit(void);
struct RastPort *qscoperastport;
static struct MPWin qscopempwin = {qscopewinspec,&qscopewinleft,qscopeinit,
{0},{{0},checkqscope,(long)&qscopempwin},{{0},close,(long)&qscopempwin},&qscoperastport};
short qscopeboxlx, qscopeboxrx, qscopeboxty, qscopeboxby;
static long checknote(long sigmask);
static void noteinit(void);
struct RastPort *noterastport;
static struct MPWin notempwin = {notewinspec,¬ewinleft,noteinit,
{0},{{0},checknote,(long)¬empwin},{{0},close,(long)¬empwin},¬erastport};
short noteboxleft, noteboxtop;
static long
close(int remake,struct MPWin *win)
{
if(win->win)
{
ObtainSemaphore(&flashysem);
*((long*)win->userdata) = 0;
win->win->RPort->Mask = 0xff; // Kludge to get around bug in 2.04 layers
closempwin(win);
if(remake)
showerr(openmpwin(win));
flashactive = spectrummpwin.win || scopempwin.win || qscopempwin.win || notempwin.win;
if((!flashactive) && (flashytaskptr))
{
flashytaskptr = 0L;
RemTask(&flashytask);
}
ReleaseSemaphore(&flashysem);
}
return(0);
}
static void
callback(struct GuidoMessage *im)
{
extern char flashactive;
if(im->Class == IDCMP_REFRESHWINDOW)
{
flashactive = 1;
if(flashytaskptr)
Signal(flashytaskptr,SIGBREAKF_CTRL_F);
}
standardcallback(im);
}
static long
checkspectrum(long sigmask)
{
if((sigmask & spectrummpwin.sigmask) && GCheckPanel(spectrummpwin.win,callback,0L))
flashflags &= ~FF_SPECTRUM, GlobPostMod(prefsglob,0);
return(0);
}
static long
checkscope(long sigmask)
{
if((sigmask & scopempwin.sigmask) && GCheckPanel(scopempwin.win,callback,0L))
flashflags &= ~FF_SCOPE, GlobPostMod(prefsglob,0);
return(0);
}
static long
checkqscope(long sigmask)
{
if((sigmask & qscopempwin.sigmask) && GCheckPanel(qscopempwin.win,callback,0L))
flashflags &= ~FF_QSCOPE, GlobPostMod(prefsglob,0);
return(0);
}
static long
checknote(long sigmask)
{
if((sigmask & notempwin.sigmask) && GCheckPanel(notempwin.win,callback,0L))
flashflags &= ~FF_NOTES, GlobPostMod(prefsglob,0);
return(0);
}
static void
spectruminit(void)
{
spectrumrastport = spectrummpwin.win->RPort;
spectrumboxleft = spectrumboxgad->LeftEdge+2;
spectrumboxtop = spectrumboxgad->TopEdge+1;
}
static void
scopeinit(void)
{
scoperastport = scopempwin.win->RPort;
scopeboxlleft = scopeboxlgad->LeftEdge+2;
scopeboxrleft = scopeboxrgad->LeftEdge+2;
scopeboxtop = scopeboxrgad->TopEdge+1;
}
static void
qscopeinit(void)
{
qscoperastport = qscopempwin.win->RPort;
qscopeboxlx = qscopeboxltgad->LeftEdge+2;
qscopeboxrx = qscopeboxrtgad->LeftEdge+2;
qscopeboxty = qscopeboxltgad->TopEdge+1;
qscopeboxby = qscopeboxlbgad->TopEdge+1;
}
static void
noteinit(void)
{
noterastport = notempwin.win->RPort;
SetAPen(noterastport,3);
noteboxleft = noteboxgad->LeftEdge+2;
noteboxtop = noteboxgad->TopEdge+1;
}
/* Unlike the other ...openclose() functions, this does NOT toggle
any particular window - it just updates the open/closed state of
all the flashy windows to reflect the state of the main window
(i.e. all flashy windows close if the main window closes) and
the flashflags in preferences. */
char *
flashywinopenclose(void)
{
extern struct Screen *playerscreen;
extern void flashyupdate(void);
char *err = 0L, *e, ff;
ff = flashactive = playerscreen ? flashflags : 0;
if(!flashytaskptr)
InitSemaphore(&flashysem);
ObtainSemaphore(&flashysem);
if(ff & FF_SPECTRUM)
{
if(!spectrummpwin.win && (e = openmpwin(&spectrummpwin)))
err = e;
}
else
setfinmpwin(&spectrummpwin);
if(ff & FF_SCOPE)
{
if(!scopempwin.win && (e = openmpwin(&scopempwin)))
err = e;
}
else
setfinmpwin(&scopempwin);
if(ff & FF_QSCOPE)
{
if(!qscopempwin.win && (e = openmpwin(&qscopempwin)))
err = e;
}
else
setfinmpwin(&qscopempwin);
if(ff & FF_NOTES)
{
if(!notempwin.win && (e = openmpwin(¬empwin)))
err = e;
}
else
setfinmpwin(¬empwin);
if((ff) && (!flashytaskptr))
{
extern void flashyupdate(void);
flashytask.tc_SPReg = flashytask.tc_SPUpper; /* Always reset the stack pointer */
if(!AddTask(&flashytask,flashyupdate,0) && (SysBase->LibNode.lib_Version >= 37))
err = "Not enough memory";
else
flashytaskptr = &flashytask;
}
ReleaseSemaphore(&flashysem);
return(err);
}
void
gui_flashywinopenclose(void)
{
showerr(flashywinopenclose());
}